﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using aspProject.Dmain.Domain;
using System.Data.Entity;

namespace aspProject.Dmain.DAL
{
    public class ProductRepository : IProductRepository
    {
        private readonly CentricEntities _context;
        private readonly DbSet<Product> _products;

        public ProductRepository(CentricEntities context)
        {
            this._context = context;
            _products = context.Products;
        }

        public IQueryable<Product> FindAll()
        {
            return _products;
        }

        public Product FindById(int productId)
        {
            return _products.SingleOrDefault(p => p.Id == productId);
        }


        public void SaveChanges()
        {
            _context.SaveChanges();
        }
    }
}
